//
//  StrategyNearbyNotesTableView.m
//  远方
//
//  Created by 1564335 on 15-6-6.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "StrategyNearbyNotesTableView.h"
#import "NotesTableViewCell.h"
@implementation StrategyNearbyNotesTableView

- (void)dealloc
{
    [_attraction release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame :(StrategyAttraction_tripsParser *)notes
{
    self.attraction = [[StrategyAttraction_tripsParser alloc] init];
    self.attraction = notes;
    [super initWithFrame:frame];
    if (self) {
        tableView1 = [[UITableView alloc] initWithFrame:CGRectMake(20, 20, self.frame.size.width, self.frame.size.height - 60) style:UITableViewStylePlain];
        tableView1.transform = CGAffineTransformMakeRotation(-M_PI / 2);
        [self addSubview:tableView1];
        tableView1.delegate = self;
        tableView1.dataSource = self;
        [tableView1 release];
    }
    return self;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    NotesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[[NotesTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
    }
    cell.image.image = nil;
    StrategyNotesParser  *notesParser = [self.attraction.arrayData objectAtIndex:indexPath.row];
    cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2);
    [cell setNotesParser:notesParser];
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.attraction.arrayData.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    StrategyNotesParser *notesParser = [self.attraction.arrayData objectAtIndex:indexPath.row];
    NSLog(@"%ld", notesParser.width);
    return 150 * notesParser.width / (CGFloat)notesParser.height;
}

@end
